home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / DVDSpecial (RU).ifs < prev    next >
Text File  |  2005-03-13  |  7KB  |  266 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=Dmitry501
  8. Title=DVDSpecial.ru
  9. Description=Imports russian movies info with small picture from DVDSpecial.ru
  10. Site=DVDSpecial.ru
  11. Language=RU
  12. Version=
  13. Requires=3.5.0
  14. Comments=
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19.  
  20. ***************************************************)
  21.  
  22. program DVDSpecial;
  23. const
  24.   BaseAddress = 'http://www.dvdspecial.ru/';
  25. var
  26.   MovieName: string;
  27.  
  28. function ParseURL(Text:String):String;
  29. var
  30.   BeginPos : Integer;
  31.   EndPos : Integer;
  32.   Value : String;
  33. begin
  34.  
  35.   repeat
  36.     BeginPos := Pos('<b>',Text);
  37.     If BeginPos > 0 Then
  38.     Begin
  39.       EndPos := Pos('</b>',Text);
  40.       Value := copy(Text, BeginPos, EndPos - BeginPos);
  41.       Value := StringReplace(Value,'<BR>',', ');
  42.       Value := StringReplace(Value,'<br>',', ');
  43.       HTMLRemoveTags(Value);
  44.       Delete(Text,1,EndPos);
  45.       If Length(result)>0 Then
  46.         result := result + ', ' + Value
  47.       else
  48.         result := Value;
  49.     end;
  50.   until BeginPos < 1;
  51.  
  52. end;
  53.  
  54. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  55. var
  56.   i: Integer;
  57. begin
  58.   result := -1;
  59.   if StartAt < 0 then
  60.     StartAt := 0;
  61.   for i := StartAt to List.Count-1 do
  62.     if Pos(Pattern, List.GetString(i)) <> 0 then
  63.     begin
  64.       result := i;
  65.       Break;
  66.     end;
  67. end;
  68.  
  69. procedure AnalyzePage(Address: string);
  70. var
  71.   ID, FilmName, Line: String;
  72.   Page: TStringList;
  73.   FilmPage: TStringList;
  74.   BeginPos, EndPos: Integer;
  75. begin
  76.   Page := TStringList.Create;
  77.   Page.Text := GetPage(Address);
  78.   BeginPos := FindLine('<B>╘╚╦▄╠█', Page,0);
  79.   if  BeginPos> 0 then
  80.     begin
  81.       //┬√ΓεΣ ⌠Φδⁿ∞εΓ Γ Σσ≡σΓε
  82.       Line:= Page.GetString(BeginPos+1); //╧εδ≤≈Φ≥ⁿ ±≥≡εΩ≤ ± αΣ≡σ±α∞Φ
  83.       PickTreeClear; //╬≈Φ±≥Ωα Σσ≡σΓα ⌠Φδⁿ∞εΓ
  84.       PickTreeAdd('╧εΦ±Ω ∩ε ±δεΓ≤: ' + MovieName, '');
  85.       repeat
  86.       BeginPos := Pos('<A HREF="film.phtml?film_id',Line);
  87.       If BeginPos>0 Then
  88.       Begin
  89.         Delete(Line,1,BeginPos); //╙ΣαδσφΦσ φα≈αδα
  90.         BeginPos:=9;
  91.         EndPos := Pos('" >  ',Line);
  92.         ID := copy(Line, BeginPos, EndPos - BeginPos); //╧εδ≤≈Φ≥ⁿ αΣ≡σ± ±≥≡αφΦ÷√
  93.         BeginPos := Pos('  ',Line)+11;
  94.         Delete(Line,1,BeginPos); //╙ΣαδσφΦσ Σε φατΓαφΦ 
  95.         BeginPos := 1;
  96.         EndPos := Pos('</A></TD>',Line)-1;
  97.         FilmName := Copy(Line, BeginPos, EndPos); //╧εδ≤≈Φ≥ⁿ φατΓαφΦσ Σδ  Γ√ßε≡α
  98.         FilmName := StringReplace(FilmName,' ',' ');
  99.         PickTreeAdd(FilmName, BaseAddress + ID);
  100.       end;
  101.       until BeginPos < 1;
  102.     end;
  103.   If  PickTreeExec(Address) Then
  104.       AnalyzeMoviePage(Address); //╧≡εαφαδΦτΦ≡εΓα≥ⁿ ±≥≡αφΦ÷≤ ± ⌠Φδⁿ∞ε∞
  105. end;
  106.  
  107. procedure AnalyzeMoviePage(Address: String);
  108. var
  109.   Page: TStringList;
  110.   LineNr : Integer;
  111.   Line, Value : String;
  112.   BeginPos, EndPos : Integer;
  113.  
  114. begin
  115.   Page := TStringList.Create;
  116.   Page.Text := GetPage(Address);
  117.   //Page.SaveToFile('c:\inet\page.txt'); //!╬≥δαΣΩα
  118.  
  119.   // URL
  120.   SetField(fieldURL,Address);
  121.  
  122.   //Rating
  123.  
  124.   LineNr := FindLine('IMDB:', Page, 0);
  125.   if LineNr > -1 then
  126.   begin
  127.     Line := Page.GetString(LineNr+3);
  128.     BeginPos := Pos('title=',Line)+7;
  129.     EndPos := Length(Line);
  130.     Value := copy(Line, BeginPos, EndPos - BeginPos);
  131.     HTMLDecode(Value);
  132.     HTMLRemoveTags(Value);
  133.     Value := Trim(Left(StringReplace(Value, '.', '   '),2));
  134.     Value := IntToStr(StrToInt(Value,0));
  135.     SetField(fieldRating,Value);
  136.   end;
  137.  
  138.   // Translated Title
  139.   LineNr := FindLine('<font class=titul> ', Page, 0);
  140.   if LineNr > -1 then
  141.   begin
  142.     Line := Page.GetString(LineNr);
  143.     HTMLDecode(Line);
  144.     HTMLRemoveTags(Line);
  145.     Value := Trim(Line);
  146.     SetField(fieldTranslatedTitle,Value);
  147.   end;
  148.   
  149.   // Original Title
  150.   LineNr := FindLine('╬≡ΦπΦφαδ:', Page, 0);
  151.   if LineNr > -1 then
  152.   begin
  153.     Line := Page.GetString(LineNr+1);
  154.     BeginPos := pos('<b>', Line);
  155.     EndPos := Length(Line);
  156.     Value := ParseURL(copy(Line, BeginPos, EndPos - BeginPos));
  157.     SetField(fieldOriginalTitle, Value);
  158.   end;
  159.  
  160.   // Year
  161.   LineNr := FindLine('┬√∩≤∙σφ:', Page, 0);
  162.   if LineNr > -1 then
  163.   begin
  164.     Line := Page.GetString(LineNr+1);
  165.     BeginPos := pos('<b>', Line);
  166.     EndPos := Length(Line);
  167.     Value := ParseURL(copy(Line, BeginPos, EndPos - BeginPos));
  168.     SetField(fieldYear, Value);
  169.   end;
  170.  
  171.   //Category
  172.   LineNr := FindLine('╞αφ≡:', Page, 0);
  173.   if LineNr > -1 then
  174.   begin
  175.     Line := Page.GetString(LineNr+1);
  176.     BeginPos := pos('<b>', Line);
  177.     EndPos := Length(Line);
  178.     Value := ParseURL(copy(Line, BeginPos, EndPos - BeginPos));
  179.     SetField(fieldCategory, Value);
  180.   end;
  181.  
  182.   //Country
  183.   LineNr := FindLine('╤≥≡αφα:', Page, 0);
  184.   if LineNr > -1 then
  185.   begin
  186.     Line := Page.GetString(LineNr+1);
  187.     BeginPos := pos('<b>', Line);
  188.     EndPos := Length(Line);
  189.     Value := ParseURL(copy(Line, BeginPos, EndPos - BeginPos));
  190.     SetField(fieldCountry, Value);
  191.   end;
  192.  
  193.   // Director
  194.   LineNr := FindLine('≡σµΦ±±σ≡:', Page, 0);
  195.   if LineNr > -1 then
  196.   begin
  197.     Line := Page.GetString(LineNr+1);
  198.     BeginPos := pos('<b>', Line);
  199.     EndPos := Length(Line);
  200.     Value := ParseURL(copy(Line, BeginPos, EndPos - BeginPos));
  201.     SetField(fieldDirector, Value);
  202.   end;
  203.  
  204.   // Producer
  205.   LineNr := FindLine('∩≡εΣ■±σ≡:', Page, 0);
  206.   if LineNr > -1 then
  207.   begin
  208.     Line := Page.GetString(LineNr+1);
  209.     BeginPos := pos('<b>', Line);
  210.     EndPos := Length(Line);
  211.     Value := ParseURL(copy(Line, BeginPos, EndPos - BeginPos));
  212.     SetField(fieldProducer, Value);
  213.   end;
  214.  
  215.   // Actors
  216.   LineNr := FindLine('┬ ≡εδ ⌡:', Page, 0);
  217.   if LineNr > -1 then
  218.   begin
  219.     Line := Page.GetString(LineNr+1);
  220.     BeginPos := pos('<b>', Line);
  221.     EndPos := Length(Line);
  222.     Value := ParseURL(copy(Line, BeginPos, EndPos - BeginPos));
  223.     SetField(fieldActors, Value);
  224.   end;
  225.  
  226.   // Description
  227.   LineNr := FindLine('<div align=justify>', Page, 0); //═α≈αδε ±≥≡εΩΦ ε∩Φ±αφΦ 
  228.   if LineNr > -1 then
  229.   begin
  230.     Line := '';
  231.     Repeat
  232.       Line := Line + Page.GetString(LineNr+1);
  233.       LineNr := LineNr+1;
  234.       EndPos := Pos('</div>',Line);
  235.     Until EndPos > 0 ;
  236.     HTMLDecode(Line);
  237.     HTMLRemoveTags(Line);
  238.     Value := Trim(Line);
  239.     SetField(fieldDescription,Value);
  240.   end;
  241.  
  242.   // Picture
  243.   LineNr := FindLine('<center><img src=', Page, 0); //═α≈αδε ±≥≡εΩΦ ± ≡Φ±≤φΩε∞
  244.   if LineNr > -1 then
  245.   begin
  246.     Line := Page.GetString(LineNr);
  247.     BeginPos := 20;
  248.     EndPos := pos('" ', Line);
  249.     Value := copy(Line, BeginPos, EndPos - BeginPos);
  250.     Address := BaseAddress+Value;
  251.     If Value <> 'foto/logo.gif' Then
  252.     begin
  253.       GetPicture(Address);
  254.     end;
  255.   end;
  256. //DisplayResults;
  257. end;
  258.  
  259. begin
  260.     MovieName := GetField(fieldOriginalTitle);
  261.     if MovieName = '' then
  262.       MovieName := GetField(fieldTranslatedTitle);
  263.     if Input('Import from DVDSpecial', 'Enter the title of the movie:', MovieName) then
  264.       AnalyzePage('http://www.dvdspecial.ru/search.phtml?keywords='+UrlEncode(MovieName)+'&target=all&logic=AND');
  265. end.
  266.